package com.example.jdbc_demo.mapper;

import com.example.jdbc_demo.entity.Student;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface StudentMapper {
    @Results(id = "studentResult", value = {
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "password", column = "password")
    })
    @Select("select * from user")
    List<Student> getAll();

    @ResultMap("studentResult")
    @Select("select * from user where id = #{number}")
    Student getStudentByNumber(String number);

    @Insert("insert into user(id,name,password) values(#{id},#{name},#{password})")
    int addStudent(Student student);
}
